<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.sql.*"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Result of Login</title>
</head>
<body>
	<% 
		String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
		String connectionURL = "jdbc:odbc:bookstore";
		String sqlQuery = "select * from account";
		Class.forName(driverName).newInstance();
		Connection con = DriverManager.getConnection(connectionURL);
		Statement statement = con.createStatement();
		ResultSet rs = statement.executeQuery(sqlQuery);
		String username = request.getParameter("user");
		String password = request.getParameter("pass");
		boolean flag = false;
		while (rs.next()) {
			if (username.equals(rs.getString(1)) && password.equals(rs.getString(2))) {
				flag = true;
				break;
			}
		}
		if (flag) {
	%>
	<p>
		You have login successfully. 
	</p>
	<p>
		If you would like to return the Index Page, please <a href="index.jsp"> click here </a>. 
	</p>
	<p>
		If you would like to logout your account, please <a href="logout.jsp"> click here </a>. 
	</p>
	<%
		}
		else {
	%>
	<p>
		Your login have been failed. The username and password is not existing in our Database.
	</p>
	 <p>
		Please <a href="login.jsp"> click here </a> to return the Login Page. 
	</p>
	<% 
		}
	%>
</body>
</html>